/**
 * 
 */
package com.et114.modules.org.cells;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.cell.Cell;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.util.HtmlBuilder;
//import org.extremecomponents.table.limit.Limit;
//import org.extremecomponents.table.core.TableConstants;

import com.et114.components.ectable.EXTableUtils;
/*
 * @author guanhw
 */
public class RolesModHrefCell implements Cell {
	protected  Log logger = LogFactory.getLog( this.getClass ( ) );
	/* (non-Javadoc)
	 * @see org.extremecomponents.table.cell.Cell#getExportDisplay(org.extremecomponents.table.core.TableModel, org.extremecomponents.table.bean.Column)
	 */
	public String getExportDisplay ( TableModel arg0 , Column arg1 ) {
		// TODO Auto-generated method stub
		return null;
	}
	
	/* (non-Javadoc)
	 * @see org.extremecomponents.table.cell.Cell#getHtmlDisplay(org.extremecomponents.table.core.TableModel, org.extremecomponents.table.bean.Column)
	 */
	public String getHtmlDisplay ( TableModel model , Column column ) {
		// TODO Auto-generated method stub
		HtmlBuilder html = new HtmlBuilder();
		html.td ( 0 ).xclose ( ) ;
		try {
			String tableId = model.getTableHandler ( ).getTable ( ).getTableId ( ) ;
			String params = EXTableUtils.getLimitPageParams ( tableId , model.getLimit ( ) ) ;
			Object bean = model.getCurrentRowBean();

			String roleId = BeanUtils.getProperty( bean, "roleId" ); //model.getLimit ( ).getSort ( ).getProperty ( )
			String roleType = BeanUtils.getProperty ( bean , "roleType" ) ; 
			String url =  "role.go?method=loadRole&roleType=" + roleType + "&roleId=" + roleId + params.toString ( ) ;
			//html.a( "javascript:go( '"+ url +"' )" );
			html.a ( url  ) ;
			html.xclose ( );
			html.img ( model.getContext().getContextPath() + "/themes/styles/default/images/edit.gif" ) ; 
			html.aEnd ( );
		} catch (Exception e) {
			logger.error ( e.getMessage ( ) , e ) ;
		}
		html.tdEnd ( );
		return html.toString();	
		}
	
}
